package com.shop.dingdongshoppingapi.util;

import redis.clients.jedis.Jedis;

public class JedisUtil {
    private static Jedis jedis;
    static {
        jedis=new Jedis("121.40.180.202",6380);
        jedis.auth("123456");
    }
    //新增
    public static void addString(String key,String val){
        jedis.set(key,val);
    }
    public static void addString(String key,String val,long seconds){
        jedis.setex(key,seconds,val);
    }
    public static void addSet(String key,String val){
        jedis.sadd(key,val);
    }

    //校验
    public static boolean checkKey(String... key){
        return jedis.exists(key)>0;
    }
    public static boolean checkSet(String key,String val){
        return jedis.sismember(key,val);
    }
    //获取
    public static String getString(String key){
        return jedis.get(key);
    }
    //删除
    public static void delKeys(String... keys){
        jedis.del(keys);
    }

}
